#include "Learner.h"

#include <stdio.h>
#include <iostream>

#include "database/TrackBase.h"
#include "io/HMMBuilder.h"
#include "io/BaseSaver.h"
#include "common.h"


Learner::Learner(const std::string baseDir, const std::string symbol) :
		baseDir(baseDir),
		baseSuffix(".lrn"),
		symbol(symbol) {
}

void Learner::isInterval(const LaserEvent& e) {
	printf("Listener notified about interval of time: %d.\n", e.time);
}
	
void Learner::isTrack(const LaserEvent& e) {
	printf("Listener notified about Track.\n");
	
	Track track = e.track;

	std::string fileName = baseDir;
	fileName += symbol;
	fileName += baseSuffix;
	
	printf("track size: %d\n", track.size());
	printf("track length: %f\n", track.length());
	if (track.size() >= 10 && track.length() >= 400) {
		printf("track accepted\n");
		BaseSaver::addTrack(fileName.c_str(), track);
	} else {
		printf("track rejected\n");
	}
}

